/* =========================================================
   1. ROOT VARIABLES & THEME
========================================================= */
:root {
    /* Colors */
    --bg-color: #f4f5f7;
    --body-bg: #e2e9f1;
    --panel-bg: #ffffff;
    --primary-color: #2c3e50;
    --accent-color: #1A5376;
    --accent-hover: #1D7480;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --header-footer-bg: #2c3e50;
    
    /* Text & Borders */
    --text-color: #34495e;
    --text-muted: #7f8c8d;
    --border-color: #e0e0e0;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(20, 2, 2, 0.05);
    --shadow-md: 0 4px 6px rgba(15, 14, 14, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.2);
    --panel-shadow: 0 10px 30px #000000;
}

/* =========================================================
   2. GLOBAL RESET & BASE STYLES
========================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-color);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* =========================================================
   3. ANIMATIONS
========================================================= */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes modalEntry {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeToast {
    0% { opacity: 0; transform: translate(-50%, 20px); }
    10% { opacity: 1; transform: translate(-50%, 0); }
    90% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, 20px); }
}

.animate-entry {
    animation: fadeInUp 0.4s ease-out forwards;
}

/* =========================================================
   4. LAYOUT STRUCTURE
========================================================= */
header {
    background: var(--header-footer-bg);
    box-shadow: var(--shadow-md);
    padding: 10px 20px;
    font-weight: 600;
    font-size: 1.2rem;
    color: white;
    letter-spacing: 0.5px;
    flex: 0 0 auto;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr; 
    align-items: center;
}
.header-title {
    text-align: center;
    white-space: nowrap; /* Keeps it on one line */
}
#btnInstructions {
    background-color: var(--danger-color) !important;
    padding: 6px 15px;
    font-size: 0.85rem;
    /* Pushes the button to the absolute right of the 3rd column */
    justify-self: end; 
}
.header-spacer {
    visibility: hidden;
}
.main-container {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.sidebar {
    width: 25%;
    min-width: 280px;
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
}

.content {
    width: 75%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

.copyright {
    flex: 0 0 auto;
    background: var(--header-footer-bg);
    padding: 5px;
    text-align: center;
    font-size: 0.9rem;
    color: white;
}

/* =========================================================
   5. PANELS & UI COMPONENTS
========================================================= */
.panel {
    background-color: var(--panel-bg);
    box-shadow: var(--panel-shadow);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.panel h3 {
    text-align: center;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #505253;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

/* --- Checklist System --- */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 4px 8px;
    transition: all 0.3s;
}
.check-text {
    display: inline-block;
    line-height: 1.4;
}

.checklist-item.active {
    color: var(--primary-color);
    font-weight: bold;
    background-color: rgba(52, 152, 219, 0.1);
    transform: translateX(5px);
    border-radius: 4px;
}

.checklist-item.done {
    color: var(--success-color);
}

.check-icon {
    width: 16px;
    height: 16px;
    border: 1px solid #bdc3c7;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 9px;
    background: white;
    transition: all 0.3s;
}

.checklist-item.done .check-icon {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* =========================================================
   6. BUTTON SYSTEM
========================================================= */
button:not(.btnReset) {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4);
}

button:active { transform: translateY(0); }

button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Specific Button Variants */
#btnInstructions {
    background-color: var(--danger-color) !important;
    padding: 6px 15px;
    font-size: 0.85rem;
    justify-self: end;
    grid-column: 3;
}

#btnInstructions:hover { background-color: var(--danger-hover); }

.panel button:not(.result-btn):not(.btnReset) {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    border: 1px solid #34495e;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    text-transform: uppercase;
    padding: 10px 15px;
}

.result-btn {
    margin-top: 15px;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    width: 100%;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.graph-download-btn {
    all: unset;
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.4rem;
    padding: 2px 4px;
    background: rgba(52, 152, 219, 0.9);
    color: white;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =========================================================
   7. GRAPHS, TABLES & FORMS
========================================================= */
.graph-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    min-height: 0;
}

.chart-wrapper {
    display: none; /* Hidden by default per logic */
    flex: 1;
    position: relative;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 5px;
    min-height: 0;
    transition: box-shadow 0.3s;
}

.chart-wrapper:hover { box-shadow: var(--shadow-md); }

/* --- Table Styles --- */
.data-table-container {
    height: 100px;
    flex: 0 0 auto;
    margin-top: 10px;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
}

.data-table th, .data-table td {
    border: 1px solid #eee;
    text-align: center;
    padding: 4px;
}

.data-table th {
    background-color: var(--primary-color);
    color: white;
}

/* --- Slider/Inputs --- */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 6px;
}

.slider-label {
    font-size: 0.8rem;
    color: #666;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.popup-slider {
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin: 2px 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.popup-slider.active {
    opacity: 1;
    pointer-events: all;
}

/* =========================================================
   8. MODALS & OVERLAYS
========================================================= */
.modal-overlay {
    position: fixed;
    top: 0; 
    left: 0;
    width: 100vw; 
    height: 100vh;
    background: transparent;
    display: none;
    justify-content: flex-end; 
    align-items: flex-start;   
    
    z-index: 1000;
}

.modal {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-top: 70px;
    margin-right: 20px; 
    
    animation: modalEntry 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 62, 80, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    opacity: 0;
    z-index: 2000;
}

.toast.show { animation: fadeToast 3s forwards; }

/* =========================================================
   9. RESPONSIVE DESIGN (MOBILE)
========================================================= */
@media screen and (max-width: 768px) {
    body { height: auto; overflow-y: auto; overflow-x: hidden; }

    .main-container { flex-direction: column; display: block; }

    .sidebar, .content { width: 100%; padding: 15px; }

    .chart-wrapper { min-height: 250px; margin-bottom: 15px; }

    header {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }

    header span { order: 1; }
    #btnInstructions { justify-self: center; order: 2; }

    input[type=range]::-webkit-slider-thumb {
        height: 24px; width: 24px;
        background: var(--accent-color);
        margin-top: -8px;
    }

    .popup-slider { height: 40px; }
    .modal { width: 90%; margin: 0 5%; }
}
/* ===== btnLoad & btnReset size reduction + centering ===== */
#btnLoad {
    padding: 4px 6px;        
    font-size: 1rem;      
    min-width: auto;
    width: 50%;
    display: block;          
    text-align: center;
}
#btnReset {
    padding: 4px 6px;
    font-size: 1 rem;
    min-width: auto;
    display: block;
    width: 50%;   
    text-align: center;
}
